import Vue from 'vue'
import Vuex from 'vuex'
import { TOKENKEY } from '@/constants'
import { getItemS, setItemS } from '@/utils/sessionStorage'
import params from '@/store/params'
import orders from '@/store/orders'
import reports from '@/store/reports'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: getItemS(TOKENKEY),
    authName: getItemS('name')
  },
  mutations: {
    setUser (state, token) {
      state.user = token
      setItemS(TOKENKEY, token)
    },
    setAuthName (state, name) {
      state.authName = name
      setItemS('name', name)
    }
  },
  actions: {},
  modules: {
    params,
    orders,
    reports
  }
})
